package dao

import (
	"context"
	"test.com/project-project/internal/data"
	"test.com/project-project/internal/database/gorms"
)

type MenuDao struct {
	conn *gorms.GormConn
}

// NewMenuDao new的目的是全局构建一个新的db对象
func NewMenuDao() *MenuDao {
	return &MenuDao{
		conn: gorms.New(),
	}
}

func (m *MenuDao) FindMenus(ctx context.Context) ([]*data.ProjectMenu, error) {
	var pms []*data.ProjectMenu
	err := m.conn.Session(ctx).Order("pid,sort asc, id asc").Find(&pms).Error
	return pms, err
}
